﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace AthCommander.Model.Shell
{
    class ShellGetFileInfo
    {
        // Ikonka
        public const uint SHGFI_ICON = 0x100;         
        
        // Nazwa wyswietlana
        public const uint SHGFI_DISPLAYNAME = 0x200;  
        
        // Typ
        public const uint SHGFI_TYPENAME = 0x400;     
        
        // Duza ikonka
        public const uint SHGFI_LARGEICON = 0x0;      

        // Mala ikonka
        public const uint SHGFI_SMALLICON = 0x1;      

        [DllImport("shell32.dll")]
        public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref ShellFileInfo psfi, uint cbSizeFileInfo, uint uFlags);

        public static ShellFileInfo GetFileInfo(string path)
        {
            ShellFileInfo info = new ShellFileInfo();
            IntPtr icon;

            icon = SHGetFileInfo(path, 0, ref info, (uint)Marshal.SizeOf(info), SHGFI_ICON | SHGFI_TYPENAME | SHGFI_SMALLICON);

            return info;
        }
    }
}
